package cn.neusoft.yp.pojo;

/**
 * Created by gaosheng on 2017/4/27.
 */
public class Product {
    //商品ID
    private String id;
    //商品名称
    private String name;
    //商品价格
    private double price;
    //商品种类
    private String category;
    //商品数量
    private int pnum;
    //商品图片地址
    private String imgurl;
    //商品描述信息
    private String description;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public int getPnum() {
        return pnum;
    }

    public void setPnum(int pnum) {
        this.pnum = pnum;
    }

    public String getImgurl() {
        return imgurl;
    }

    public void setImgurl(String imgurl) {
        this.imgurl = imgurl;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public int hashCode() {
        return 31+id==null?0:id.hashCode();
    }
    @Override
    public boolean equals(Object obj) {
        //说明当前对象不可能为nulll
        if(obj==null){
            return false;
        }
        //说明当前对象和obj对象都不为null
        if(this==obj){
            return true;
        }
        //当前对象可能是Product类的对象，obj可能是也可能不是Product类的对象
        //判断obj是否为Product类对象
        if(!(obj instanceof Product)){
            return false;
        }
        //说明obj是Product类的对象
        Product other = (Product)obj;
        //判断两个对象的id是否相同
        return id != null && id.equals(other.getId());
    }

}
